package com.guiwu.gteway.industryapp.Api.Urlmodule;

import com.guiwu.gteway.industryapp.Api.http.Urls;

import java.net.URL;
import java.util.List;

import okhttp3.HttpUrl;

/**
 * Created by 乔冠 on 2017/12/25. 请求url地址集合
 */

public class UrlGet {

    /**
     * 用户登录url
     * @return
     */
    public static String urlForLogin(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/users/login").toString();
    }

    /**
     * 短信验证码url
     * @return
     */
    public static String urlForVertifyCode(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/users/sms").toString();
    }

    /**
     * 查询用户信息
     * @return
     */
    public static String urlForUserInfo(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/users").toString();
    }

    /**
     * 注册新用户
     * @return
     */
    public static String urlForRegiste(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/users").toString();
    }

    /**
     * 修改密码
     */
    public static String urlForChangePassword(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/users/password").toString();
    }

    /**
     * 获取用户绑定的萤石云信息
     * @return
     */
    public static String urlForAppKey(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/camera/user").toString();
    }

    /**
     * 获取用户下挂网关
     * @return
     */
    public static String urlForGetGateWayGroup(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/users/devices")
                .toString();
    }

    /**
     * 获取网关下摄像头信息
     * @return
     */
    public static String urlForGetCameraInfo(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/camera/netgate")
                .toString();
    }

    /**
     * 获取摄像头的accessToken
     * @return
     */
    public static String urlForAccesstoken(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/camera/token")
                .toString();
    }

    /**获取网关下监控点
     * @return
     */
    public static String urlForGetMonitorPoint(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/dataPoints")
                .toString();
    }

    /**
     * 获取监控点的数据
     * @return
     */
    public static String urlForGetMonitorData(String gateWayId){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_ONE_NET)
                .addPathSegment("devices").addPathSegment(gateWayId)
                .addPathSegment("datapoints")
                .toString();
    }

    /**
     * 控制监控点
     * @param gateWayId
     * @return
     */
    public static String urlForControlMonitor(String gateWayId){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_ONE_NET)
                .addPathSegment("cmds").addQueryParameter("device_id",gateWayId)
                .toString();
    }

    /**
     * 查询网关下事件号
     * @return
     */
    public static String urlForQueryEventList(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/devices/event")
                .toString();
    }

    /**
     *  查询网关下事件绑定的寄存器
     * @return
     */
    public static String urlForRegistEvent(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/devices/eventBind")
                .toString();
    }


    /**
     *  查询当前报警记录
     * @return
     */
    public static String urlForAlarmNow(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/triggers/current")
                .toString();
    }


    /**
     *  查询历史报警
     * @return
     */
    public static String urlForAlarmHistory(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/triggers/data")
                .toString();
    }

    /**
     *  批量查询网关状态
     * @param ids
     * @return
     */
    public static String urlForGateWaysState(List<String> ids){
        HttpUrl.Builder builder = new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_ONE_NET)
                .addPathSegments("devices/status");
        StringBuilder sb = new StringBuilder();
        for (int i = 0 ;i < ids.size() ; i++){
            sb.append(ids.get(i));
            if (i != ids.size() -1)
                sb.append(",");
        }
        return builder.addQueryParameter("devIds",sb.toString()).toString();
    }

    public static String urlForDimGateWayState(){
        HttpUrl.Builder builder = new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_ONE_NET)
                .addPathSegment("devices");
        return builder.toString();
    }


    //获取网关分享者
    public static String urlForGateWayShareName(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/devices/share")
                .toString();
    }

    //获取网关联网类型
    public static String urlForGateWayConnectType(){
        return new HttpUrl.Builder().scheme(Urls.SCHEME).host(Urls.HOST_GUIWU).port(Urls.PORT)
                .addPathSegments("dataPlatform/devices")
                .toString();
    }
}
